package hotel.compare.oversea.controller;

import com.alibaba.fastjson.JSONObject;
import hotel.base.oversea.dto.master.CompareHotelBasicRoomDto;
import hotel.base.oversea.entity.master.CompareHotelBasicRoom;
import hotel.base.oversea.utils.Result;
import hotel.compare.oversea.service.CompareHotelBasicRoomService;
import hotel.compare.oversea.service.CompareHotelRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 校验后酒店房型
 *
 * @author HuangT
 * @date 2020/6/30 17:19
 */
@Slf4j
@RestController
@RequestMapping("/compareHotelBasicRoom")
@Api(value = "CompareHotelBasicRoomController", tags = {"校验后酒店房型信息"})
public class CompareHotelBasicRoomController {

    @Autowired
    private CompareHotelBasicRoomService compareHotelBasicRoomService;

    @Autowired
    private CompareHotelRoomService compareHotelRoomService;

    @GetMapping("/getHotelBasicRoomInfo")
    @ApiOperation(value = "获取校验后酒店房型信息")
    public Result<Object> compareHotelRoomBySub() {
        return compareHotelBasicRoomService.getHotelBasicRoomInfo();
    }

    @PostMapping("/updateCreateStateById")
    @ApiOperation(value = "更新创建状态")
    public Result<Object> updateCreateStateById(@RequestBody CompareHotelBasicRoomDto hotelBasicRoomInfo) {
        return compareHotelBasicRoomService.updateCreateStateById(hotelBasicRoomInfo);
    }

    /**
     * 获取创建的物理房型id
     */
    @PostMapping("/getCompareHotelBasicRoomInfo")
    public Result<CompareHotelBasicRoom> getCompareHotelBasicRoomInfo(@RequestBody JSONObject jsonObject){
        log.info("============进入了控制器==========");
        int switchRoomId=jsonObject.getInteger("switchRoomId");
        int mtRoomId=jsonObject.getInteger("mtRoomId");
        return compareHotelBasicRoomService.getCompareHotelBasicRoomInfo(switchRoomId,mtRoomId);
    }
    /**
     * @author: lmf
     * @date: 2020/9/19 16:26
     * 根据携程的母酒店id + 母物理房型id 获取到美团对应的酒店id+ 房型id
     */
    @PostMapping("/getHotelRoomInfo")
    public Result<CompareHotelBasicRoom> getHotelRoomInfo(@RequestBody JSONObject jsonObject){
        log.info("============进入了效验房型控制器==========");
        int roomId=jsonObject.getInteger("roomId");
        int masterHotelId=jsonObject.getInteger("masterHotelId");
        return compareHotelBasicRoomService.getHotelRoomInfo(masterHotelId,roomId);
    }

    /**
     * 根据携程物理房型id+美团的母物理房型id 获取是否有映射数据
     */
    @PostMapping("/getHotelRoomInfoBySwitchRoomIdAndMtRoomId")
    public Result<CompareHotelBasicRoom> getHotelRoomInfoBySwitchRoomIdAndMtRoomId(@RequestBody JSONObject jsonObject){
        log.info("============进入了效验房型控制器,请求参数为{}==========");
        int switchRoomId=jsonObject.getInteger("switchRoomId");
        int mtRoomId=jsonObject.getInteger("mtRoomId");
        return compareHotelBasicRoomService.getHotelRoomInfoBySwitchRoomIdAndMtRoomId(switchRoomId,mtRoomId);
    }

    /**
     * 根据美团酒店id+美团房型id 获取是否有映射
     */
    @PostMapping("/getHotelRoomInfoByMtHotelIdAndMtRoomId")
    public Result<CompareHotelBasicRoom> getHotelRoomInfoByMtHotelIdAndMtRoomId(@RequestBody JSONObject jsonObject){
        log.info("============进入了效验房型控制器,请求参数为{}==========");
        int mtHotelId=jsonObject.getInteger("mtHotelId");
        int mtRoomId=jsonObject.getInteger("mtRoomId");
        return compareHotelBasicRoomService.getHotelRoomInfoByMtHotelIdAndMtRoomId(mtHotelId,mtRoomId);
    }
    /**
     * 根据美团酒店id+美团房型id 获取是否有映射
     */
    @PostMapping("/removeHotelRoomInfoByMtHotelIdAndMtRoomId")
    public Result<Object> removeHotelRoomInfoByMtHotelIdAndMtRoomId(@RequestBody JSONObject jsonObject){
        log.info("============进入了效验房型控制器,请求参数为{}==========");
        int mtHotelId=jsonObject.getInteger("mtHotelId");
        int mtRoomId=jsonObject.getInteger("mtRoomId");
        return compareHotelBasicRoomService.removeHotelRoomInfoByMtHotelIdAndMtRoomId(mtHotelId,mtRoomId);
    }
    /**
     * 针对美团的酒店进行房型重新匹配
     */
    @PostMapping("/compareHotelRoomByHotelIdSql")
    public Result<Object> compareHotelRoomByHotelIdSql(@RequestBody JSONObject jsonObject){
        log.info("============进入了效验房型控制器,请求参数为{}==========",jsonObject);
        int mtHotelId=jsonObject.getInteger("mtHotelId");
        return compareHotelRoomService.compareHotelRoomByHotelIdSql(mtHotelId);
    }

    /***
    * @Author: lmf
    * @Date: 2021/2/3
     * 根据携程酒店id+携程母物理房型id删除映射关系
    */
    @PostMapping("/removeHotelRoomInfoByHotelIdAndRoomId")
    public Result<Object> removeHotelRoomInfoByHotelIdAndRoomId(@RequestBody JSONObject jsonObject){
        log.info("============进入了根据携程酒店id+携程房型id效验房型控制器,请求参数为{}==========");
        int hotelId=jsonObject.getInteger("hotelId");
        int masterBaiscRoomId=jsonObject.getInteger("masterBaiscRoomId");
        return compareHotelRoomService.removeHotelRoomInfoByHotelIdAndRoomId(hotelId,masterBaiscRoomId);
    }




}
